package com.example.mapper;

import com.example.pojo.Room;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface RoomMapper {
    List<Room> selectRoomByRole(@Param("role") String role,@Param("keyword")String keyword,
                                @Param("status") String status, @Param("typeId") Integer typeId,
                                @Param("ownerId")Integer ownerId,@Param("roomId") Integer roomId);

    @Select("select * from room where id = #{id}")
    Room selectById(Integer id);

    Integer add(Room room);

    void updateById(Room room);

    @Delete("delete from room where id = #{id}")
    void deleteById(Integer id);


    @Select("select * from room where name = #{name}")
    Room selectByUsename(String name);


    /**
     * 统计指定类型的房间数量
     */
    int countByTypeId(Integer typeId);

    void updateCommentCount(@Param("roomId") Integer roomId, @Param("count") Integer count);

    @Update("update room set status = #{status} where id = #{roomId}")
    void updateStatus(@Param("roomId") Integer roomId,@Param("status") String status);

    // 统计每个状态的数量
    Map<String, Integer> getRoomStatistics(Integer ownerId);
}
